package com.wushi.lenovo.asia5b.app_ui.other.dialog;

import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.mvp.base.BaseDialog;
import com.mvp.images.WImageLoader;
import com.wushi.lenovo.asia5b.R;
import com.wushi.lenovo.asia5b.app_model.good.goodbean.OrderGoodBean;
import com.wushi.lenovo.asia5b.app_ui.other.activity.PhotoPreviewActivity;

import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by zhangyuncai on 2019/3/16.
 */
public class NgDialog extends BaseDialog {
    @BindView(R.id.tv_ng_num)
    TextView tv_ng_num;//ng图片数量
    @BindView(R.id.iv_ng_img)
    ImageView iv_ng_img;//ng图片第一张
    @BindView(R.id.tv_ng_content)
    TextView tv_ng_content;//ng内容
    @BindView(R.id.rl_ng_img_vessel)
    RelativeLayout rl_ng_img_vessel;
    private final OrderGoodBean bean;
    private List<String> ng_images;

    public NgDialog(Context context, OrderGoodBean bean) {
        super(context);
        this.bean = bean;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.dialog_ng;
    }

    @Override
    protected void initView() {
        if (bean != null) {
            //图片数量
            ng_images = bean.getNg_images();
            if (ng_images != null && ng_images.size() != 0) {
                rl_ng_img_vessel.setVisibility(View.VISIBLE);
                tv_ng_num.setText(String.format("+%d", ng_images.size()));
                WImageLoader.displayImage(getContext(), ng_images.get(0), iv_ng_img);
            } else {
                rl_ng_img_vessel.setVisibility(View.GONE);
            }
            //ng描述
            tv_ng_content.setText(bean.getNg_description());
            //ng第一张图片
        }
    }

    @Override
    protected void initListener() {

    }

    @OnClick({R.id.bt_dialog_ok, R.id.rl_ng_img_vessel})
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.bt_dialog_ok:
                dismiss();
                break;
            case R.id.rl_ng_img_vessel:
                if (ng_images != null) {
                    PhotoPreviewActivity.startPhotoViewActivity(getContext(), ng_images);
                }
                break;
        }
    }

    @Override
    protected int getGravity() {
        return Gravity.CENTER;
    }
    @Override
    protected int getWidthStyle() {
        return getScreenWidth(0.8f);
    }
}
